package com.next.aappublicapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;

public class TwitterFeedActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_twitter_feed);
		try{
			WebView twitterWebView = (WebView)findViewById(R.id.twitter_web_view);
			String twitterData = "<a class=\"twitter-timeline\" href=\"https://twitter.com/AamAadmiParty\" data-widget-id=\"339326037013958656\">Tweets by @AamAadmiParty</a>" +
					"<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\"://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>";
			String base64 = android.util.Base64.encodeToString(twitterData.getBytes("UTF-8"), android.util.Base64.DEFAULT);
			twitterWebView.loadData(twitterData, "text/html; charset=UTF-8", base64);
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.twitter_feed, menu);
		return true;
	}

}
